home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / keyb / lock.zip / LOCK.ASM < prev    next >
Assembly Source File  |  1990-01-28  |  6KB  |  241 lines

  1. title Password Locked System Program.
  2. page 60,120            ; page length = 60
  3.                 ; page width  = 120
  4. ;
  5. ;    This program lock a system to protect open network connections.
  6. ;
  7. ;    LOCK : Copyright (c) 1989 by John Wolchak.  
  8. ;    This program is released into the Public Domain.
  9. ;
  10. ;    John Wolchak.
  11. ;    56 Physics Building
  12. ;    University of Saskatchewan.
  13. ;    Saskatoon, Saskatchewan
  14. ;    Canada     S7K 0W0
  15. ;    Phone: (306) 966-4852
  16. ;    NetNorth (BITNET): Wolchak@Sask
  17. ;    Inter_Network: Wolchak@Admin.Usask.Ca
  18. ;
  19. ;    To assemble:
  20. ;    masm lock,,,
  21. ;    link lock,,,
  22. ;    exe2bin lock.exe lock.com
  23. ;
  24. code segment
  25. assume cs:code,ds:code
  26. org 100h
  27.  
  28. start:        jmp beginning
  29. ;
  30. ;        Data Area
  31. ;
  32. exit_code    db    02h        ; Help message displayed.
  33. v_error        db    13,10,"Password verification failed",13,10,"$"
  34. u_prompt    db    13,10,13,10,"Unlock Password> $"
  35. l_prompt    db    13,10,"Lock Password> $"
  36. v_prompt    db    13,10,"Verification> $"
  37. s_pass        dw    00h        ; Size of password.
  38. d_pass        db    80 dup(0)    ; Original Password.
  39. v_pass        db    80 dup(0)    ; Verification Password.
  40. dos_maj        db    00h        ; DOS major version.
  41. dos_min        db    00h        ; DOS minor version.
  42. author        db    "Lock by Password System Program.",13,10
  43.         db    "V1.0 (c) 23-Nov-1989 by John Wolchak.",13,10
  44.         db    13,10
  45. help        db    "Usage:        LOCK",13,10,9,9
  46.         db    13,10
  47.         db    "Example:    lock ",13,10,9,9
  48.         db    "Lock Password> ",13,10,9,9
  49.         db    "Verification> ",13,10,9,9
  50.         db    13,10,9,9
  51.         db    "Unlock Password> ",13,10
  52.         db    "$"
  53. ;
  54. ;        Code Area
  55. ;
  56. Beginning:
  57.         mov si, 80h        ; Offset of command line.
  58.         lodsb            ; Get a byte.
  59.         cmp al, 00h        ; Is there any data.
  60.         jz get_ver        ; Yes. Jump.
  61.         cmp al, 0dh        ; Is there any data.
  62.         jz get_ver        ; Yes. Jump.
  63. dis_help:
  64.         mov dx, offset author    ; Help message.
  65.         mov ah, 09h        ; Display it.
  66.         int 21h
  67.         mov exit_code, 00h    ; Command, help issued.
  68.         jmp nor_term        ; Exit.
  69.  
  70. get_ver:    
  71.         mov ah, 30h        ; Get DOS version number.
  72.         int 21h
  73.  
  74.         mov dos_maj, al        ; Save major version.
  75.         mov dos_min, ah        ; Save minor version.
  76.  
  77.         cmp ah, 01h
  78.         jnz cont
  79.         mov exit_code, 01h    ; No MS-DOS version 1.x.
  80.         jmp nor_term        ; Exit.
  81.  
  82. cont:
  83.         lodsb            ; Get a byte.
  84.         cmp al, " "        ; Is it leading blank.
  85.         jz cont            ; Yes.  Loop.
  86.         cmp al, 09h        ; Is it leading tab.
  87.         jz cont            ; Yes.  Loop.
  88.         cmp al, 0dh        ; Is it a carriage return.
  89.         jnz dis_help        ; Yes. dis_help.
  90.  
  91. again:
  92. ;        Get the lock password.
  93.         mov ax, offset d_pass    ; Where we will store
  94.         mov di, ax        ;   the password.
  95.         mov bx, 00h        ; Password size.
  96.  
  97. ;        Display the prompt.
  98.         mov dx, offset l_prompt    ; lock password prompt.
  99.         mov ah, 09h        ; Display it.
  100.         int 21h
  101.  
  102. ;        Direct Charater Input without echo.
  103. l_loop:        mov ah, 07h        ; Read a character.
  104.         int 21h            ; Get it.
  105.  
  106. ;        Get the password,
  107. ;        and convert to upper case.
  108.         cmp al, " "        ; Is it a blank.
  109.         jz l_loop        ; Yes.  Loop.
  110.         cmp al, 09h        ; Is it a tab.
  111.         jz l_loop        ; Yes.  Loop.
  112.         cmp al, 0dh        ; Is it the end.
  113.         jz l_got        ; Yes. We got it.
  114.         cmp al, "z"        ; Is
  115.         jg l_not        ;   it
  116.         cmp al, "a"        ;     lower
  117.         jb l_not        ;       case?
  118.         sub al, 20h        ; Make it upper case.
  119. l_not:
  120.         inc bx            ; Count the characters.
  121.         stosb            ; Save the byte.
  122.         cmp bx, 80h        ; Too long.
  123.         jz again        ; Yes. Try again.
  124.         jmp l_loop
  125.  
  126. l_got:
  127.         cmp bx, 00h        ; Do we have data.
  128.         jnz l_cont        ; No quit.
  129.         mov exit_code, 02h    ; Program abort.
  130.         jmp nor_term
  131.  
  132. l_cont:
  133.         mov s_pass, bx        ; Save the size.
  134.         mov ax, offset v_pass    ; Where we will store
  135.         mov di, ax        ;   the password.
  136.         mov bx, 00h        ; Password size.
  137.  
  138. ;        Display the prompt.
  139.         mov dx, offset v_prompt    ; Verify password prompt.
  140.         mov ah, 09h        ; Display it.
  141.         int 21h
  142.  
  143. ;        Direct Charater Input without echo.
  144. v_loop:        mov ah, 07h        ; Read a character.
  145.         int 21h            ; Get it.
  146.  
  147. ;        Get the password,
  148. ;        and convert to upper case.
  149.         cmp al, " "        ; Is it a blank.
  150.         jz v_loop        ; Yes.  Loop.
  151.         cmp al, 09h        ; Is it a tab.
  152.         jz v_loop        ; Yes.  Loop.
  153.         cmp al, 0dh        ; Is it the end.
  154.         jz v_got        ; Yes. We got it.
  155.         cmp al, "z"        ; Is
  156.         jg v_not        ;   it
  157.         cmp al, "a"        ;     lower
  158.         jb v_not        ;       case?
  159.         sub al, 20h        ; Make it upper case.
  160. v_not:
  161.         inc bx            ; Count the characters.
  162.         stosb            ; Save the byte.
  163.         cmp bx, 80h        ; Too long.
  164.         jz ver_err        ; Yes. Try again.
  165.         jmp v_loop
  166.  
  167. v_got:
  168.         cmp s_pass, bx        ; Is it the wrong size?
  169.         jnz ver_err        ; Yes try it again.
  170.  
  171.         mov di, offset v_pass    ; Set destination.
  172.         mov si, offset d_pass    ; Set Source.
  173.         mov cx, s_pass
  174.         rep cmpsb        ; Does it verify.
  175.         jz unl_pass        ; Yes. Jump out.
  176.  
  177. ;        Display error message.
  178. ver_err:
  179.         mov dx, offset v_error    ; Error message.
  180.         mov ah, 09h        ; Display it.
  181.         int 21h
  182.         jmp again
  183.         
  184. ;        Unlock password.
  185. unl_pass:
  186.         mov ax, offset v_pass    ; Where we will store
  187.         mov di, ax        ;   the password.
  188.         mov bx, 00h        ; Password size.
  189.  
  190. ;        Display the prompt.
  191.         mov dx, offset u_prompt    ; Unlock password prompt.
  192.         mov ah, 09h        ; Display it.
  193.         int 21h
  194.  
  195. ;        Direct Charater Input without echo.
  196. u_loop:        mov ah, 07h        ; Read a character.
  197.         int 21h            ; Get it.
  198.  
  199. ;        Get the password,
  200. ;        and convert to upper case.
  201.         cmp al, " "        ; Is it a blank.
  202.         jz u_loop        ; Yes.  Loop.
  203.         cmp al, 09h        ; Is it a tab.
  204.         jz u_loop        ; Yes.  Loop.
  205.         cmp al, 0dh        ; Is it the end.
  206.         jz u_got        ; Yes. We got it.
  207.         cmp al, "z"        ; Is
  208.         jg u_not        ;   it
  209.         cmp al, "a"        ;     lower
  210.         jb u_not        ;       case?
  211.         sub al, 20h        ; Make it upper case.
  212. u_not:
  213.         inc bx            ; Count the characters.
  214.         stosb            ; Save the byte.
  215.         cmp bx, 80h        ; Too long.
  216.         jz unl_pass        ; Yes. Try again.
  217.         jmp u_loop
  218.  
  219. u_got:
  220.         cmp s_pass, bx        ; Is it the wrong size?
  221.         jnz unl_pass        ; Yes try it again.
  222.  
  223.         mov di, offset v_pass    ; Set destination.
  224.         mov si, offset d_pass    ; Set Source.
  225.         mov cx, s_pass
  226.         rep cmpsb        ; Does it verify.
  227.         jz next            ; Yes. Jump out.
  228.  
  229.         jmp unl_pass
  230.         
  231. next:
  232.  
  233. ;        Exit the program.
  234. nor_term:
  235.         mov al, cs:[exit_code]    ; Set termination code.
  236.         mov ah, 4ch        ; Termination.
  237.         int 21h
  238.  
  239. code ends
  240.      end start
  241.